//
//  WaterRecodCell.m
//  ForestPack
//
//  Created by 骆锴 on 2018/8/3.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "WaterRecodCell.h"
#import "WaterRecordModel.h"

@interface WaterRecodCell ()

@property (nonatomic, strong) UILabel *eventLabel;
@property (nonatomic, strong) UILabel *moneyLabel;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UILabel *numberLabel;

@end

@implementation WaterRecodCell

+ (WaterRecodCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"MyCommissionCell";
    WaterRecodCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[WaterRecodCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    
    return cell;
}

- (void)createSubView {
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(14), ScreenX375(260), ScreenX375(12))];
    self.timeLabel.textColor = REXADECIMALCOLOR(@"#999999");
    self.timeLabel.font = Kfont(12);
    [self addSubview:self.timeLabel];
    
    UIImageView *line = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(36) - 0.5, SCREEN_WIDTH - ScreenX375(26), 0.5)];
    line.image = [UIImage imageNamed:@"虚线"];
    [self addSubview:line];
    
    self.eventLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(45), ScreenX375(260), ScreenX375(18))];
    self.eventLabel.textColor = REXADECIMALCOLOR(@"#333333");
    self.eventLabel.font = Kfont(14);
    [self addSubview:self.eventLabel];
    
    self.moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(113), ScreenX375(45), ScreenX375(100), ScreenX375(18))];
    self.moneyLabel.textColor = ThemeColor;
    self.moneyLabel.font = Kfont(12);
    self.moneyLabel.textAlignment = NSTextAlignmentRight;
    [self addSubview:self.moneyLabel];
    
    self.numberLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(67), ScreenX375(260), ScreenX375(14))];
    self.numberLabel.textColor = REXADECIMALCOLOR(@"#999999");
    self.numberLabel.font = Kfont(12);
    [self addSubview:self.numberLabel];
}

-(void)initWithModel:(WaterRecordModel *)model{
    self.timeLabel.text = model.time;
    self.eventLabel.text = model.way_name;
    self.numberLabel.text = model.order_no;
    if ([model.type isEqualToString:@"1"]) {
        NSString *money = [NSString stringWithFormat:@"+%@元",model.amount];
        self.moneyLabel.textColor = ThemeColor;
        self.moneyLabel.text = money;
    }else{
        NSString *money = [NSString stringWithFormat:@"-%@元",model.amount];
        self.moneyLabel.textColor = REXADECIMALCOLOR(@"#2227ed");
        self.moneyLabel.text = money;
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
